package com.py.credit.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import com.py.credit.entity.BatchLog;
import com.py.credit.entity.Table;
import com.py.framework.core.common.Page;

/**
 * 采集批次日志dao
 * 
 * @author jicm
 *
 */
public interface BatchLogDao {

	/**
	 * 添加批次日志
	 * 
	 * @param batchId
	 * @param target
	 * @param type
	 * @param dataSourceId
	 * @param deptId
	 * @param managerId
	 * @param status
	 */
	public void addBatchLog(@Param(value = "batchId") String batchId, @Param(value = "target") int target,
			@Param(value = "type") String type, @Param(value = "dataSourceId") int dataSourceId,
			@Param(value = "deptId") Long deptId, @Param(value = "managerId") Long managerId,
			@Param(value = "status") String status, @Param(value = "result") String result);

	public BatchLog selectPermissionLimit(@Param(value = "batchId") String batchId,
			@Param(value = "deptId") Long deptId, @Param(value = "regionId") Long regionId,
			@Param(value = "userType") int userType);

	/**
	 * 根据batchId获取采集批次详情
	 * 
	 * @param batchId
	 * @return
	 */
	public BatchLog select(@Param(value = "batchId") String batchId);

	/**
	 * 获取当前用户的部门
	 * 
	 * @param managerId
	 * @return
	 */
	@Deprecated
	public String getDeptOidFormanagerId(@Param(value = "managerId") int managerId);

	/**
	 * 获取当前用户一级部门绑定的表
	 * 
	 * @param deptId
	 * @param code
	 * @return
	 */
	public List<Table> selectTableForDept(@Param(value = "region") Long region, @Param(value = "deptId") Long officeId,
			@Param(value = "code") String code);

	public void modifyStatus(@Param(value = "batchId") String batchId, @Param(value = "clz") String clz);

	public void modifyBatchLog(@Param(value = "batchId") String batchId, @Param(value = "result") String result,
			@Param(value = "tcount") int tcount, @Param(value = "scount") int scount,
			@Param(value = "fcount") int fcount, @Param(value = "rcount") int rcount,
			@Param(value = "waitCount") int waitCount, @Param(value = "status") String status);

	public List<Map<String, Object>> selectByCondition(@Param(value = "deptId") String deptId,
			@Param(value = "columns") List<String> columns, @Param(value = "conditions") List<String> conditions);

	public List<Map<String, Object>> getErrorDataByConditionForPage(@Param(value = "columns") List<String> columns,
			@Param(value = "additionalColumns") String[] additionalColumns,
			@Param(value = "conditions") List<String> conditions, @Param(value = "managerId") Long managerId,
			@Param(value = "deptId") String deptId, @Param(value = "code") String code,
			@Param(value = "topDeptId") Long topDeptId, @Param(value = "startTime") String startTime,
			@Param(value = "endTime") String endTime, @Param(value = "tableName") String tableName,
			@Param(value = "page") Page page, @Param(value = "regionId") Long regionId,
			@Param(value = "userType") int userType, @Param(value = "userDeptId") Long userDeptId);

	public List<Map<String, Object>> selectByConditionForPage(@Param(value = "columns") List<String> columns,
			@Param(value = "additionalColumns") String[] additionalColumns,
			@Param(value = "conditions") List<String> conditions, @Param(value = "page") Page page,
			@Param(value = "topDeptId") Long topDeptId, @Param(value = "managerId") Long managerId,
			@Param(value = "userType") int userType, @Param(value = "deptId") Long deptId);

	public List<Map<String, Object>> selectDoubleByConditionForPage(@Param(value = "columns") List<String> columns,
															  @Param(value = "additionalColumns") String[] additionalColumns,
															  @Param(value = "conditions") List<String> conditions, @Param(value = "page") Page page,
															  @Param(value = "topDeptId") Long topDeptId, @Param(value = "managerId") Long managerId,
															  @Param(value = "userType") int userType, @Param(value = "deptId") Long deptId);

	public List<Map<String, Object>> selectDoubleFrByConditionForPage(@Param(value = "columns") List<String> columns,
																	@Param(value = "additionalColumns") String[] additionalColumns,
																	@Param(value = "conditions") List<String> conditions, @Param(value = "page") Page page,
																	@Param(value = "topDeptId") Long topDeptId, @Param(value = "managerId") Long managerId,
																	@Param(value = "userType") int userType, @Param(value = "deptId") Long deptId);

	public String selectTypeForManagerId(@Param(value = "managerId") int managerId);

	public List<Map<String, Object>> selectLogQueryListByConditionForPage(
			@Param(value = "columns") List<String> columns,
			@Param(value = "additionalColumns") String[] additionalColumns,
			@Param(value = "conditions") List<String> conditions, @Param(value = "page") Page page,
			@Param(value = "topDeptId") Long topDeptId, @Param(value = "regionId") Long regionId,
			@Param(value = "userType") int userType, @Param(value = "deptId") Long deptId);

	public List<Map<String, Object>> getLogQueryBieByCondition(@Param(value = "conditions") List<String> conditions,
			@Param(value = "topDeptId") Long topDeptId, @Param(value = "regionId") Long regionId,
			@Param(value = "userType") int userType, @Param(value = "deptId") Long deptId);

	public List<Map<String, Object>> getLogQueryBar(@Param(value = "startTime") String startTime,
			@Param(value = "endTime") String endTime, @Param(value = "type") String type);

	public Map<String, Object> selectData(@Param(value = "managerId") Long managerId,
			@Param(value = "deptId") String deptId, @Param(value = "code") String code,
			@Param(value = "startTime") String startTime, @Param(value = "endTime") String endTime,
			@Param(value = "tableId") String tableId, @Param(value = "regionId") Long regionId,
			@Param(value = "topDeptId") Long topDeptId, @Param(value = "userType") int userType,
			@Param(value = "userDeptId") Long userDeptId);

	/**
	 * @return
	 */
	public Map<String, Object> selectCollectionInfo();

	/**
	 * @return
	 */
	public List<Map<String, Object>> selectCollectionAnalysis();

	/**
	 * @return
	 */
	public List<Map<String, Object>> selectDeptRkNum();

	/**
	 * @return
	 */
	public List<BatchLog> selectUnAssociatedBatch();

	/**
	 * @param id
	 */
	public void updateBatchLogAssociationStatus(@Param(value = "id") String id, @Param(value = "status") String status);

	/**
	 * 
	 * @Function 获取入库日志柱状图
	 * @FileName BatchLogDao.java
	 * @MethodName logQueryBarView
	 * @param deptId
	 * @return
	 * @Date 2018年5月29日 下午7:02:40
	 * @Author Min DongXv
	 *
	 */
	public List<Map<String, Object>> logQueryBarView(@Param(value = "startDate") String startDate,
			@Param(value = "endDate") String endDate, @Param(value = "topDeptId") Long topDeptId,
			@Param(value = "regionId") Long regionId, @Param(value = "userType") int userType,
			@Param(value = "deptId") Long deptId);

	/**
	 * 
	 * @Function 获取最近5条的数据采集操作
	 * @FileName BatchLogServiceImpl.java
	 * @MethodName getLastUpload
	 * @param topDeptId
	 *            顶级部门ID
	 * @param regionId
	 *            区域ID
	 * @param deptId
	 *            部门ID
	 * @param userType
	 *            用户类型
	 * @return
	 * @Date 2018年6月22日 下午3:44:46
	 * @Author Min DongXv
	 *
	 */
	public List<Map<String, Object>> getLastUpload(@Param(value = "topDeptId") Long topDeptId,
			@Param(value = "regionId") Long regionId, @Param(value = "deptId") Long deptId,
			@Param(value = "userType") int userType, @Param(value = "userId")Long userId);
	public List<Map<String, Object>> getDoubleLastUpload(@Param(value = "topDeptId") Long topDeptId,
												   @Param(value = "regionId") Long regionId, @Param(value = "deptId") Long deptId,
												   @Param(value = "userType") int userType, @Param(value = "userId")Long userId);

	public List<Map<String, Object>> getDoubleFrLastUpload(@Param(value = "topDeptId") Long topDeptId,
														 @Param(value = "regionId") Long regionId, @Param(value = "deptId") Long deptId,
														 @Param(value = "userType") int userType, @Param(value = "userId")Long userId);

	public List<Map<String, Object>> getBatchDetailForPage(@Param(value = "columns") List<String> columns,
			@Param(value = "page") Page page, @Param(value = "topDeptId") Long topDeptId,
			@Param(value = "regionId") Long regionId, @Param(value = "tableId") Integer tableId,
			@Param(value = "deptId") Long deptId, @Param(value = "userType") int userType,
			@Param(value = "startTime") String startTime, @Param(value = "endTime") String endTime);

	public void updateBatchLogWaitCount(@Param(value = "batchId") String batchId,
			@Param(value = "waitCount") int waitCount);

	/**
	 * 
	 * @Function 异常数据处理时错误减正确加
	 * @FileName BatchLogServiceImpl.java
	 * @MethodName updateSFcount
	 * @param batchId
	 *            批次号
	 * @return
	 * @Author Min DongXv
	 *
	 */
	public void updateSFcount(@Param(value = "batchId") String batchId);

	/**
	 * 
	 * @Function 删除异常数据时错误减总数减
	 * @FileName BatchLogServiceImpl.java
	 * @MethodName updateSFcount
	 * @param batchId
	 *            批次号
	 * @return
	 * @Author Min DongXv
	 *
	 */
	public void updateTFcount(@Param(value = "batchId") String batchId);

	/**
	 * 
	 * @Function 重复数据修改时进行重复减正确加
	 * @FileName BatchLogServiceImpl.java
	 * @MethodName updateSRcount
	 * @param batchId
	 *            批次号
	 * @return
	 * @Author Min DongXv
	 *
	 */
	public void updateSRcount(@Param(value = "batchId") String batchId);

	/**
	 * 
	 * @Function 删除正确数据时总数减正确数减
	 * @FileName BatchLogServiceImpl.java
	 * @MethodName updateSRcount
	 * @param batchId
	 *            批次号
	 * @return
	 * @Author Min DongXv
	 *
	 */
	public void updateTScount(@Param(value = "batchId") String batchId);

	/**
	 * 
	 * @Function 删除重复数据时总数减重复数减
	 * @FileName BatchLogServiceImpl.java
	 * @MethodName updateTRcount
	 * @param batchId
	 *            批次号
	 * @return
	 * @Author Min DongXv
	 *
	 */
	public void updateTRcount(@Param(value = "batchId") String batchId);

	public int selectCountByAssociation(@Param(value = "status") String status);

	public List<String> selectBatchIdByOfficeId(@Param(value = "officeId") long officeId);

	public Map<String, Object> selectTotal(@Param(value = "deptId")Long deptId, @Param(value = "userId")Long userId);

	public void RedBlackAutoPush();

	public void updatebaseInfo(@Param(value = "sql")String sql);

	public void FrcjAutoPush();

	public void ZrrcjAutoPush();

	public void ZrrjlAutoPush();

	
	/**
	 * @Title: UpdateCollectionState
	 * @Description: TODO(这里用一句话描述这个方法的作用)
	 * @param     设定文件
	 * @return void    返回类型
	 * @throws
	*/
	
	public void UpdateCollectionState();

	public List<Map<String, Object>> getTenLastUpload(@Param(value = "topDeptId") Long topDeptId,
			   @Param(value = "regionId") Long regionId, @Param(value = "deptId") Long deptId,
			   @Param(value = "userType") int userType, @Param(value = "userId")Long userId);

	public List<Map<String, Object>> selectTenByConditionForPage(@Param(value = "columns") List<String> columns,
			  @Param(value = "additionalColumns") String[] additionalColumns,
			  @Param(value = "conditions") List<String> conditions, @Param(value = "page") Page page,
			  @Param(value = "topDeptId") Long topDeptId, @Param(value = "managerId") Long managerId,
			  @Param(value = "userType") int userType, @Param(value = "deptId") Long deptId);


}
